/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jfonia.view.symbols;

import java.awt.Graphics2D;
import org.jfonia.connect5.basics.BasicValueNode;
import org.jfonia.connect5.basics.MutableValueNode;
import org.jfonia.connect5.basics.ValueNode;
import org.jfonia.connect5.relations.Equal;
import org.jfonia.constants.SymbolConstants;

/**
 *
 * @author Rik Bauwens
 */
public class LedgerLineSymbol extends RankedStaffSymbol
{
        private MutableValueNode<Double> lineWidthNode;

        public LedgerLineSymbol(ValueNode<Double> frameX, ValueNode<Double> staffY,
                                MutableValueNode<Double> staffBase, MutableValueNode<Double> postStaffBase,
                                ValueNode<Double> xNode, MutableValueNode<Double> widthNode,
                                MutableValueNode<Integer> rankNode)
        {
                super(frameX, staffY, staffBase, postStaffBase, xNode, new BasicValueNode(0.0), rankNode);
                lineWidthNode = new BasicValueNode<Double>(0.0);
                new Equal<Double>(widthNode, lineWidthNode);
        }

        protected void updateNodes()
        {

        }

        @Override
        public void paintSymbol(Graphics2D g)
        {
                super.paintSymbol(g);
                g.drawLine((int) Math.ceil(getX()- SymbolConstants.LEDGER_LINE_PRE_SPACING),
                           (int) Math.ceil(getY()),
                           (int) Math.ceil(getX() + lineWidthNode.getValue() + SymbolConstants.LEDGER_LINE_POST_SPACING),
                           (int) Math.ceil(getY()));
        }

}
